<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<title>祖龙娱乐  - BI系统</title>
	<link href="../../css/component.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../../js/highcharts.js"></script>
	<script type="text/javascript" src="../../js/drawChart.js"></script>
</h:head>

<h:body>
	<ui:param name="bean" value="#{eventClientAction}" />
	
	<span class="pagetitle">客户端分析 —— 事件分析</span>
	<p:separator />
	
	<!-- 右侧页面顶部查询部分 -->
	<h:form id="fsearch">
		<p:growl id="growl" showDetail="true" sticky="true" />
        <p:dataTable id="dlist0" value="#{bean}" scrollable="true" resizableColumns="true" paginator="false" style="text-align:center;">
	        <p:column headerText="开始日期" styleClass="column" style="width:160px">
					<p:calendar value="#{bean.dateStart}" mode="popup" pattern="yyyy-MM-dd" />
			</p:column>
			<p:column headerText="结束日期" styleClass="column" style="width:160px">
				<p:calendar value="#{bean.dateEnd}" mode="popup" pattern="yyyy-MM-dd" />
			</p:column>
			<p:column headerText="平台" styleClass="column" style="width:90px">
				<p:selectOneMenu id="platformSel" styleClass="queryPlatform" value="#{bean.queryPlatform}">
			        <f:selectItems value="#{bean.platformItmes}" />
			        <p:ajax update="channelSel" listener="#{bean.updateChannelItmes}" />
		        </p:selectOneMenu>
	        </p:column>
        	<p:column headerText="渠道" styleClass="column" style="width:130px">
       			 <p:selectOneMenu id="channelSel" styleClass="queryChannel" value="#{bean.queryChannel}">
	        		<f:selectItems value="#{bean.channelItmes}" />
	        		<p:ajax update="platformSel" listener="#{bean.updateServerItmes}" />
        		</p:selectOneMenu>
       		</p:column>
        	<p:column id="eventTypeId" headerText="事件类型" style="width:180px">
				<p:selectOneMenu id="eventTypeSel" styleClass="queryServer" value="#{bean.queryBean.eventTypeId}">
	       			 <f:selectItems value="#{bean.eventTypeItmes}" />
	        	     <p:ajax update="eventId dlist0" listener="#{bean.updateEventName}" />
       			 </p:selectOneMenu>
       		 </p:column>
	        <p:column id="eventId" headerText="事件名称" style="width:180px">
		        <p:selectOneMenu id="eventNameSel" styleClass="queryServer" value="#{bean.queryBean.eventId}">
			         <f:selectItems value="#{bean.eventNameItmes}" />
			         <p:ajax update="eventTypeId dlist0" listener="#{bean.updateEventTypeName}" />
		        </p:selectOneMenu>
	        </p:column>
			<p:column headerText="操作" style="width:50px">
        		<p:commandButton value="查询" action="#{bean.search()}" update=":data" ajax="false" />
        	</p:column>
        </p:dataTable>
	</h:form>
	<br />

	<!-- 数据展示部分，包含表格和图表 -->
	<h:form id="dform">
		<h:panelGrid columns="1" style="width:100%">
            <div id="basewidth" style="width:92%;height:0;border:0;">
			</div>
         </h:panelGrid>
	
		<div class="data" id="data">
    		<p:panel id="panel" header="查询结果" style="margin-bottom:10px;">
    			<p:dataGrid id="chart" var="c" value="#{bean.eventsChart}" columns="1" layout="grid">
					<p:selectOneMenu value="#{bean.selectItem}" styleClass="queryServer" style="width:50px">
			            <f:selectItems value="#{bean.allItmes}" />
			            <p:ajax update="chart" listener="#{bean.handleEventsChange}" />
		          	</p:selectOneMenu>
		        	
			        <p:panel style="text-align:center">
			            <h:panelGrid columns="1" style="width:100%">
			                <div id="highchartChart1" style="width:100%;height:300px; border:0;">
								<script type="text/javascript">
									generateChart('#{c.jsonStr}', '#{c.jsonType}', '1');
								</script>  
							</div>
			            </h:panelGrid>
			        </p:panel>
			    </p:dataGrid>
    			
    			<br />
				<p:dataTable id="dlist" var="l" value="#{bean.events}" scrollable="true" resizableColumns="true" paginator="true" paginatorPosition="top" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}  {Exporters}" rowsPerPageTemplate="15,30" rows="15" style="text-align:center;">
					<f:facet name="{Exporters}">
						<h:commandLink  styleClass="exporter">
					        <p:graphicImage url="/resources/images/excel.png" height="25px"/>
					        <p:dataExporter type="xls" target="dlist" fileName="events-#{pageHelper.getNewDateDetailStr()}"/>
					    </h:commandLink>
					</f:facet>
					
					<p:column headerText="日期" styleClass="column" style="width:80px">
						<h:outputLabel value="#{l.dateStr}" />
					</p:column>
					<p:column headerText="事件类型" styleClass="column" style="width:120px">
						<h:outputLabel value="#{l.eventTypeName}" />
					</p:column>
					<p:column headerText="事件ID" styleClass="column" style="width:60px">
						<h:outputLabel value="#{l.eventId}" />
					</p:column>
					<p:column headerText="事件名称" styleClass="column" style="width:170px">
						<h:outputLabel value="#{l.eventName}" />
					</p:column>
					<p:column headerText="完成事件次数" styleClass="column" style="width:70px">
						<h:outputLabel value="#{l.finishnum}" />
					</p:column>
					<p:column headerText="完成事件设备数" styleClass="column" style="width:80px">
						<h:outputLabel value="#{l.uuidnum}" />
					</p:column>
					<p:column headerText="完成事件帐号数" styleClass="column" style="width:80px">
						<h:outputLabel value="#{l.useridnum}" />
					</p:column>
					<p:column headerText="完成事件角色数" styleClass="column" style="width:80px">
						<h:outputLabel value="#{l.roleidnum}" />
					</p:column>
				</p:dataTable>
    		</p:panel>
		</div>
	</h:form>

	<!-- 页脚 -->
	<div class="footer"></div>
</h:body>
</html>